<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div class="pro_list fr"  >
   <div class="title"  >
   	 <span class="titletxt">您现在的位置：</span>
     <ul> 
       <li class="root">会员中心</li>        
       <li>客户管理</li>  
       <li>供货商代理</li>            
     </ul>
   </div>
  <c:if test="${not empty ret }">
   	<c:if test="${ret.code ne '200'}">
   		<script type="text/javascript">alertError('${ret.result}');</script>
   		<div id=messager class="messager" >
	         <div class="contentmsg">
	             <h5>提示信息～！</h5>
	             <ul>
	               <li>${ret.result}</li>
	             </ul>
	        </div>
	     <div class="closer" onClick="showHideLayer('messager');" title="关闭"></div>
	    </div>
   	</c:if>
   </c:if>
<br/>
<div  class="easyui-panel" title="代理客户"  style="">
    <div data-options="region:'north',title:'',split:true" style="height:40px;background-color:#e4e4e4;">
    	<form action="" id="searchForm" name="searchForm">
    	<table>
    		<tr>
				<td class="screen-n"><span>中文名称</span></td>
				<td class="screen-n">
					<input type="text" id="s_chsName" class="screen-input" style="width:200px" onkeydown="pms.kd13('initBuyers')">
				</td>
				<td class="screen-n"><span>是否存在登录账号</span></td>
				<td class="screen-n">
				    <select name="isMember" id="isMember" style="width:80px;" class="easyui-combobox" panelheight="auto">
				       <option value="">全部</option>
					   <option value="0">否</option>
					   <option value="1">是</option>
				    </select>
				</td>
				<td class="screen-n">
					<input type="button" class="button" value="查询" onclick="initAgentProvider()">
					<input type="button" class="button" value="重置" onclick="pms.resetForm('searchForm')" >
				</td>
			</tr>
			</table>
		</form>
    </div>
    <div data-options="region:'center',split:true" style="width: 100%;height:431px">
		<table id="tableGrid" ></table>
	</div>
	<form  action='<c:url value="/agentuser/doAgentProvider.s"/>' method="post" name="agentForm">
	　　　<input type="hidden" name="code" id="code"/>
　　</form>
</div>
</div>
<script>
var agentProvidersTable;
$(function(){
	
	initAgentProvider();
});

function initAgentProvider(){
   	agentProvidersTable = $('#tableGrid').pDataGrid({
		 columns:[[
	          	   {field:'chsName',title:'中文名称',align:'center'},
	               {field:'providerCode',title:'供应商编号',align:'center'},
	               {field:'spell',title:'拼音码',align:'center'},
	               {field:'phone',title:'电话',align:'center'},
	               {field:'mobile',title:'手机',align:'center'},
	               {field:'consigner',title:'委托人',align:'center'},
	               {field:'productionScope',title:'生产经营范围',align:'center'},
	               {field:'levelId',title:'会员等级',align:'center',formatter:function(value){
						if(value=="1"){
							return '普通会员';
						}else{
							return '高级会员';
						}
		           }},
		           {field:'action',title : '操作',align : 'center',
						formatter : function(value, row, index) {
							var str = '';
							    str+=' <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="agentUser(\''+row.providerCode+'\')">代理供货商</a>';
							return str;
						}
					} 
		          ]],
		    url:'<c:url value="/agentuser/searchPageAgentProvider.s"/>',  
		    pagination:true,
		    pageSize:30,
		    queryParams:{
		    	"chsName":$('#s_chsName').val(), 
				"isMember":$('#isMember').combobox('getValue')
		    },
			completeCallback:function(data){
				if(data.code == "100"){
					alertError(data.result);
				}else{
					 
				}
			}
	}); 
}

function agentUser(code){
	if(confirm('确认代理此供货商操作？')){
		$("#code").val(code);
		document.forms["agentForm"].submit();
	} 
}
</script>